/**
 * 
 */
package com.base.myproject.server;

import java.sql.ResultSet;

import com.base.myproject.server.database.PoolMan;

/**
 * @author zgw
 *2009-11-5 下午09:21:32
 * javazgw@gmail.com
 */
public class FindUser {

	/**
	 * 根据用户编码和密码查找是否存在该用户
	 * @param user
	 * @param pass
	 * @return
	 */
	static boolean isHaveUser(String user,String pass)
	{
		String sql = "select count(*) as c from bcode where bcode='"+user+"' and password='"+pass+"'";
		
		PoolMan pm = new PoolMan();
		try {
			ResultSet rs = pm.executeQuery(sql);
			if(rs.next())
			{
				 if(!rs.getString("c").equals("0"))
				 {
					 return true;
				 }
			}
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		return false;
	}
	/**
	 * 根据用户名和密码判断是否存在用户
	 * @param name
	 * @param pass
	 * @return
	 */
	static boolean isHaveUserbyName(String name,String pass)
	{
		String sql = "select count(*) as c from bcode where bname='"+name+"' and password='"+pass+"'";
		
		PoolMan pm = new PoolMan();
		try {
			ResultSet rs = pm.executeQuery(sql);
			if(rs.next())
			{
				 if(!rs.getString("c").equals("0"))
				 {
					 return true;
				 }
			}
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		return false;
	}
	
	/**
	 * 根据用户名和密码判断是否存在用户,加入了下载权限的判断
	 * @param name
	 * @param pass
	 * @return
	 */
	static boolean isHaveUserbyName_filter_download(String name,String pass)
	{
		String sql = "select count(*) as c from bcode where bname='"+name+"' and password='"+pass+"' and candownload=1";
		
		PoolMan pm = new PoolMan();
		try {
			ResultSet rs = pm.executeQuery(sql);
			if(rs.next())
			{
				 if(!rs.getString("c").equals("0"))
				 {
					 return true;
				 }
			}
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		return false;
	}
}
